import time

from selenium import webdriver
from selenium.webdriver.common.by import By

class Testcase:
    def __init__(self):
        # 初始化对象
        self.driver = webdriver.Chrome()

    def get_shopex123(self):
        self.driver.get('https://ecshop.test2.shopex123.com/')
        # 点击注册
        self.driver.find_element(By.XPATH,'//*[@id="ECS_MEMBERZONE"]/a[2]').click()
        # 在用户名输入框输入内容
        time.sleep(2)
        self.driver.find_element(By.XPATH,'//*[@id="username"]').send_keys('阮继鹏')
        # 输入邮箱
        time.sleep(2)
        self.driver.find_element(By.XPATH,'//*[@id="email"]').send_keys('997300610@qq.com')
        # 输入密码
        time.sleep(2)
        self.driver.find_element(By.XPATH,'//*[@id="password1"]').send_keys('ruanjipeng123')
        # 确认密码
        time.sleep(2)
        self.driver.find_element(By.XPATH,'//*[@id="confirm_password"]').send_keys('ruanjipeng123')
        # 点击注册
        self.driver.find_element(By.XPATH,'//*[@id="main"]/div[2]/form/div[9]/input[3]').click()

        # 已经注册，点击立即登录跳转
        self.driver.find_element(By.XPATH,'//*[@id="sidebar"]/div[2]/a').click()
        # 输入用户名
        time.sleep(2)
        self.driver.find_element(By.XPATH,'//*[@id="body"]/div[1]/div/div[1]/form/div[1]/div/input').send_keys('阮继鹏')
        # 输入密码
        time.sleep(2)
        self.driver.find_element(By.XPATH,'//*[@id="body"]/div[1]/div/div[1]/form/div[2]/div/input').send_keys('ruanjipeng123')
        # 点击登录
        time.sleep(2)
        self.driver.find_element(By.XPATH,'//*[@id="body"]/div[1]/div/div[1]/form/input[3]').click()

        # 搜索框输入内容
        time.sleep(5)
        self.driver.find_element(By.ID,'keyword').send_keys('洗面奶')

        # 点击搜索按钮
        time.sleep(2)
        self.driver.find_element(By.CLASS_NAME,'btn_search').click()

        # 点击退出账号
        time.sleep(3)
        self.driver.find_element(By.XPATH,'//*[@id="ECS_MEMBERZONE"]/font/a[2]').click()

    # 退出浏览器
    def quit(self):
        time.sleep(4)
        self.driver.quit()


if __name__ == '__main__':
    case = Testcase()
    case.get_shopex123()
    case.quit()




